var t = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../utils/util")), a = getApp();

Page({
    data: {
        show1: !1,
        show2: !1,
        datas: []
    },
    onLoad: function(t) {
        this.initData();
    },
    goPay: function(t) {
        wx.navigateTo({
            url: "/packageD/warranty/policyPay/policyPay?id=" + t.currentTarget.dataset.id + "&supplier_id=" + t.currentTarget.dataset.supplier_id
        });
    },
    edit: function(t) {
        wx.navigateTo({
            url: "/packageD/warranty/Edit_Balance_manage/Edit_Balance_manage?id=" + t.currentTarget.dataset.id
        });
    },
    delete: function(t) {
        var e = this, n = t.currentTarget.dataset.id;
        wx.showModal({
            content: "此操作将永久删除该保单, 是否继续??",
            title: "提示",
            success: function(t) {
                if (t.confirm) {
                    var s = a.getNetAddresss("plugin.supplier.frontend.insurance.insurance-del");
                    s += "&id=" + n, a._getNetWork({
                        url: s,
                        success: function(t) {
                            var a = t.data;
                            console.log(a), 1 == a.result ? (wx.showToast({
                                title: a.msg,
                                icon: "none",
                                duration: 1e3
                            }), e.initData()) : wx.showToast({
                                icon: "none",
                                title: a.msg,
                                duration: 1500
                            });
                        },
                        fail: function(t) {
                            console.log(t);
                        }
                    });
                } else t.cancel && console.log("用户点击取消");
            }
        });
    },
    edshow: function(t) {
        console.log(t), console.log(this.data.datas), this.data.datas[t.currentTarget.dataset.lis].edit_active = !this.data.datas[t.currentTarget.dataset.lis].edit_active, 
        this.setData({
            datas: this.data.datas
        });
    },
    tapAdd: function() {
        wx.navigateTo({
            url: "/packageD/warranty/Add_Balance_manage/Add_Balance_manage"
        });
    },
    gojilu: function(t) {
        console.log(t.currentTarget.dataset.id), wx.navigateTo({
            url: "/packageD/warranty/warrantyAdd/warrantyAdd?id=" + t.currentTarget.dataset.id
        });
    },
    TimeFilter: function(t) {
        if (!t) return null;
        var a = new Date(1e3 * t);
        return a.getFullYear() + "-" + ((a.getMonth() + 1 < 10 ? "0" + (a.getMonth() + 1) : a.getMonth() + 1) + "-") + ((a.getDate() < 10 ? "0" + a.getDate() : a.getDate()) + " ") + ((a.getHours() < 10 ? "0" + a.getHours() : a.getHours()) + ":") + ((a.getMinutes() < 10 ? "0" + a.getMinutes() : a.getMinutes()) + ":") + (a.getSeconds() < 10 ? "0" + a.getSeconds() : a.getSeconds());
    },
    lastTime: function(t) {
        if (!t) return null;
        var a = Date.parse(new Date()) / 1e3, e = parseInt((t - a) / 86400);
        return e ? e + "天后到期" : "已到期";
    },
    initData: function() {
        var e = this, n = a.getNetAddresss("plugin.supplier.frontend.insurance.index");
        a._getNetWork({
            url: n,
            success: function(a) {
                var n = a.data;
                if (console.log(n), 1 == n.result) {
                    for (var s = 0; s < n.data.list.length; s++) n.data.list[s].edit_active = !1, n.data.list[s].is_time = t.default.formatTimeTwo(n.data.list[s].pay_time, "Y/M/D h:m:s"), 
                    n.data.list[s].lo_time = e.lastTime(n.data.list[s].lost_time);
                    console.log(n.data.list), e.setData({
                        datas: n.data.list,
                        goods_length: n.data.list.length,
                        pay_status: n.data.set.ins_pay_status,
                        renew_status: n.data.set.ins_renew_status,
                        phone1: n.data.set.ins_phone_1,
                        phone_2: n.data.set.ins_phone_2
                    }), console.log(e.data.datas);
                } else wx.showToast({
                    icon: "none",
                    title: n.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    showpop: function(t) {
        var e = this, n = t.currentTarget.dataset.id;
        wx.showModal({
            content: "确认续保吗?",
            title: "提示",
            success: function(t) {
                if (t.confirm) {
                    var s = a.getNetAddresss("plugin.supplier.frontend.insurance.contInsurance");
                    s += "&ins_id=" + n, a._getNetWork({
                        url: s,
                        success: function(t) {
                            var a = t.data;
                            console.log(a), 1 == a.result ? (wx.showToast({
                                title: a.msg,
                                icon: "none",
                                duration: 1e3
                            }), e.initData()) : wx.showToast({
                                icon: "none",
                                title: a.msg,
                                duration: 1500
                            });
                        },
                        fail: function(t) {
                            console.log(t);
                        }
                    });
                } else t.cancel && console.log("用户点击取消");
            }
        });
    },
    isCoverLayer: function() {
        this.setData({
            show1: !1,
            show2: !1
        });
    },
    tapdel: function() {
        this.setData({
            show2: !1
        });
    },
    callphoto: function() {
        this.setData({
            show2: !0,
            show1: !1
        });
    },
    onReady: function() {},
    onShow: function() {
        this.initData();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});